package drugdealer.gui.components;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class PessoalComposite extends Composite {
	private Label[] label;
	private Text cpfEntry;
	private Text nomeEntry;
	private Text rgEntry;
	private Text emailEntry;
	private Text[] telefoneEntry;
	private DateComposite dataNasc;
	
	public PessoalComposite(Composite parent, boolean editing) {
		super(parent, SWT.NONE);
 		this.setLayout(new GridLayout(7, false));
		
		final int labels = 6;
		this.label = new Label[labels];
		
		this.label[0] = new Label(this, SWT.NONE);
		this.label[0].setText("CPF");
		this.cpfEntry = new Text(this, SWT.BORDER);
		this.cpfEntry.setTextLimit(11);
		this.cpfEntry.setEditable(!editing);

		this.label[1] = new Label(this, SWT.NONE);
		this.label[1].setText("RG");
		this.rgEntry = new Text(this, SWT.BORDER);
		
		this.label[2] = new Label(this, SWT.NONE);
		this.label[2].setText("Nome");
		this.nomeEntry = new Text(this, SWT.BORDER);
		
		this.label[3] = new Label(this, SWT.NONE);
		this.label[3].setText("Data de Nasc.");
		this.dataNasc = new DateComposite(this);
		
		this.label[4] = new Label(this, SWT.NONE);
		this.label[4].setText("Email");
		this.emailEntry = new Text(this, SWT.BORDER);
		
		this.label[5] = new Label(this, SWT.NONE);
		this.label[5].setText("Telefones");
		
		final int telefones = 3;
		telefoneEntry = new Text[telefones];
		for (int i = 0; i < telefones; i++)
			this.telefoneEntry[i] = new Text(this, SWT.BORDER);
		
		//Define layout
		this.cpfEntry.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 3, 1));
		this.rgEntry.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1));
		this.nomeEntry.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 6, 1));
		this.dataNasc.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 6, 1));
		this.emailEntry.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 6, 1));
		for (int i = 0; i < telefones; i++)
			this.telefoneEntry[i].setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true, 2, 1));
		for (int i = 0; i < labels; i++)
			this.label[i].setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, true, 1, 1));
		
	}
	
}
